import 'package:fish_redux/fish_redux.dart';
import '../../../app_files.dart';
import '../model/order_view_model.dart';

class OrderResultEditState implements Cloneable<OrderResultEditState> {
  List<OrderConfigModel> items;
  CheckListItemModel model;
  TextEditingController textEditingController = TextEditingController();

  @override
  OrderResultEditState clone() {
    return OrderResultEditState()
      ..items = items
      ..model = model
      ..textEditingController = textEditingController;
  }
}

OrderResultEditState initState(Map<String, dynamic> args) {
  List<OrderConfigModel> items = args['items'];
  CheckListItemModel model = args['info'];
  String resStr = OrderConfigModel.getResultStr(items);
  UserInfoEntity userInfo = GlobalStore.store.getState().userInfo;
  String workerName = args['workerName'];
  workerName = workerName.length != 0 ? workerName : userInfo.nickname;
  List<String> orderInfo = [
    '安检员：   $workerName',
    '安检单编号：${model.checkOrderNo}',
    '安检时间：${model.checkTime}',
    '安检结果：${model.checkStatusStr}',
  ];

  return OrderResultEditState()
    ..model = model
    ..items = items
    ..textEditingController.text = orderInfo.join('\r\n') + '\r\n' + resStr;
}
